<?php
	// Verification si il y a des pieces jointes :
	$PJExist = false;
	$reqPJ = "SELECT * FROM pieces_jointes WHERE idPagePj = ".$idSsPage."";
	$queryPJ = $bdd->query($reqPJ);
	while ($PJ = $queryPJ->fetch()){
		$PJExist = true;
	}$queryPJ->closeCursor();
	
	if ($PJExist){
		// Si il y en a, on les affiche
		$queryPJ = $bdd->query($reqPJ);
		while ($PJ = $queryPJ->fetch()){
			
			if($_GET['page'] == "Admin"){
				echo'
				<form action = "ctrl_Administration.php" method = "post" />
				<img src="../img/icons/'.substr($PJ['fichierPj'], -3).'-icon.png" /> <a href="../piecesJointes/'.$PJ['fichierPj'].'" target="_blank">'.$PJ['libellePj'].'</a>
				<input src = "../img/icons/cross.png" type = "image" value ="submit" /> 
				<input type = "hidden" name = "idPj" value = "'.$PJ['idPj'].'" />
				<input type = "hidden" name = "do" value = "deletePj" />
				</form>';
			}else{
			echo '<img src="../img/icons/'.substr($PJ['fichierPj'], -3).'-icon.png" /> <a href="../piecesJointes/'.$PJ['fichierPj'].'" target="_blank">'.$PJ['libellePj'].'</a><br />';
			}
		}$queryPJ->closeCursor();
	}
?>